const WebServerAccessKey = 'bb6bd652af8d247d1cd0e9a07359c08d'
const axios = require('axios')
const  GetPositionWeather = async (req, res) => {
    const {city} = req.body
      const result =  await  axios.get('https://restapi.amap.com/v3/weather/weatherInfo',{
        params:{
            key: WebServerAccessKey,
            city: city,
            extensions:'base',
            output:'JSON'
        }
    })
    if(result.data.status === '1'){
        res.send(result.data.lives[0])
    }else{
        res.send({
            code: 500,
            message: '获取天气失败'
        })
    }
    
}
module.exports =GetPositionWeather